//
//  StudioStateCollectionViewCell.m
//  Arts1
//
//  Created by 孤星晨宇 on 15/9/23.
//  Copyright (c) 2015年 Arts1. All rights reserved.
//

#import "StudioStateCollectionViewCell.h"
#import "AllHeader.h"

@implementation StudioStateCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        UIView *whiteView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH - 20, 60 )];
        whiteView.backgroundColor = [UIColor whiteColor];
        whiteView.layer.cornerRadius = 4;
        whiteView.layer.masksToBounds = YES
        ;
        [UIView viewShadowColor:whiteView];
        
        _lineView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 4, 60)];
        //  _lineView.layer.cornerRadius = 5;
        _lineView.backgroundColor = kColorforRandomColor;
//        [UIView viewRediusForTopAndBottomForLeft:_lineView withRedius:5];
        [whiteView addSubview:_lineView];
        
        _titlelabel = [[UILabel alloc] initWithFrame:CGRectMake(15, 0, 200, 30)];
        _titlelabel.text = @"中央美术学院2016年考试时间安排";
        _titlelabel.font = [UIFont systemFontOfSize:13];
        [whiteView addSubview:_titlelabel];
        
        _detailLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, _titlelabel.bottom, 200, 30)];
        _detailLabel.text = @"中央美术学院2016年考试";
        _detailLabel.font = [UIFont systemFontOfSize:10];
        [whiteView addSubview:_detailLabel];
        
        _calendarBTN = [UIButton buttonWithType:(UIButtonTypeCustom)];
        _calendarBTN.frame = CGRectMake(whiteView.width - 60, 15 , 50, 30);
        _calendarBTN.titleLabel.font = [UIFont systemFontOfSize:12];
        [_calendarBTN setTitle:@"报名" forState:(UIControlStateNormal)];
        [_calendarBTN setTitleColor:[UIColor blackColor] forState:(UIControlStateNormal)];
        [whiteView addSubview:_calendarBTN];
        
        _rightView = [[UIImageView alloc] initWithFrame:CGRectMake(whiteView.width - 40, 15 , 30 , 30 )];
        _rightView.image = [UIImage imageNamed:@"8.jpeg"];
        _rightView.backgroundColor = [UIColor redColor];
        [whiteView addSubview:_rightView];
        
        _circle = [[UIView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - 45, 27.5 , 8 , 8 )];
        _imageLayer = [CALayer layer];
        _imageLayer.frame = CGRectMake(0, 0, _circle.width, _circle.height);
        _imageLayer.cornerRadius = 4.0;  //设置layer圆角半径
        _imageLayer.masksToBounds = YES;  //隐藏边界
        _imageLayer.backgroundColor = (__bridge CGColorRef _Nullable)(kRandomColor);
        _imageLayer.borderWidth = 1.0;
        _imageLayer.borderColor = kColorforRandomColor.CGColor;
        [_circle.layer addSublayer:_imageLayer];
        
        [whiteView addSubview:_circle];
        
        [self.contentView addSubview:whiteView];

    }
    return self;
}

- (void)setIndex:(NSInteger)index{
    _index = index;
    if (_index == 0) {
        _imageLayer.frame = CGRectZero;
        _rightView.frame = CGRectZero;
        _circle.frame = CGRectZero;
    } else if (_index == 1){
        _lineView.backgroundColor = kCustomColor(174, 232, 103, 1);
        _calendarBTN.frame = CGRectZero;
        _imageLayer.frame = CGRectZero;
        _circle.frame = CGRectZero;
    }else {
        UIColor *color = kRandomColor;
        _lineView.backgroundColor = color;
        _imageLayer.borderColor = color.CGColor;
        _calendarBTN.frame = CGRectZero;
        _rightView.frame = CGRectZero;
    }
}

- (void)setState:(SSStateModel *)state{
    _state = state;
    _titlelabel.text = _state.title;
    _detailLabel.text = _state.addTime;

}







@end
